package com.dys.designpattern.abstractfactory;

import com.dys.designpattern.abstractfactory.factory.AppliancesFactory;
import com.dys.designpattern.abstractfactory.factory.HairFactory;
import com.dys.designpattern.abstractfactory.product.AbstractFreezer;
import com.dys.designpattern.abstractfactory.product.AbstractTV;
import com.dys.designpattern.abstractfactory.product.AbstractWasher;

/**
 * @Author: 疾风
 * @ClassName: Client
 * @Description: 客户端
 * @CreateDate: 2024/05/27
 * @Version: v1.0.0
 */
public class Client {

    AbstractTV tv;
    AbstractFreezer freezer;
    AbstractWasher washer;

    public Client(AppliancesFactory factory) {
        // 在客户端看来就是使用工厂方法来生产家电
        this.tv = factory.createTV();
        this.freezer = factory.createFreezer();
        this.washer = factory.createWasher();
    }

    public AbstractTV getTv() {
        return tv;
    }

    public void setTv(AbstractTV tv) {
        this.tv = tv;
    }

    public AbstractFreezer getFreezer() {
        return freezer;
    }

    public void setFreezer(AbstractFreezer freezer) {
        this.freezer = freezer;
    }

    public AbstractWasher getWasher() {
        return washer;
    }

    public void setWasher(AbstractWasher washer) {
        this.washer = washer;
    }

    public static void main(String[] args) {
        Client client = new Client(new HairFactory());
        AbstractTV tv1 = client.getTv();
        System.out.println(tv1);
        AbstractFreezer freezer1 = client.getFreezer();
        System.out.println(freezer1);
        AbstractWasher washer1 = client.getWasher();
        System.out.println(washer1);
    }
}
